package com.sky.controller.admin;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/shop")
@Api(tags = "营业状态")
@Slf4j
public class ShopController {

    public static final String SHOP_STATUS_KEY = "SHOP_STATUS";

    @Autowired
    public RedisTemplate redisTemplate;

    /**
     * 获取营业状态
     */
    @GetMapping("/status")
    public Result getStatus() {
        Object status = redisTemplate.opsForValue().get(SHOP_STATUS_KEY);
        return Result.success(status);
    }

    /**
     * 修改营业状态
     */
    @PutMapping("/{status}")
    public Result updateStatus(@PathVariable Integer status) {
        redisTemplate.opsForValue().set(SHOP_STATUS_KEY,status);
        return Result.success();
    }
}
